package org.example.dubbo.linkconsumer.controller;

import org.example.dubbo.linkapi.User;
import org.example.dubbo.linkapi.UserService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.ApplicationContext;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;

@RestController
@RequestMapping("/hello")
public class HelloController {
    @Autowired
    private UserService userService;
    @Autowired
    private ApplicationContext context;

    @GetMapping("/user/{id}")
    public User getUser(@PathVariable("id")Integer id) {
        String[] str=context.getBeanDefinitionNames();
        for (String string : str) {
            System.out.println("..."+string);
        }
        return userService.queryUserById(id);
    }
}
